package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.WorkflowProductService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.WorkflowProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author: DuYaTao
 * @ Date: 2025/9/23 - 10:28
 */

@RestController
@RequestMapping("/workflowProduct")
public class WorkflowProductController {

    @Autowired
    private WorkflowProductService workflowProductService;

    @GetMapping("/page")
    public Result<PageInfo<WorkflowProduct>> getWorkflowProductByPage(WorkflowProduct workflowProduct, @RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer size){
        return workflowProductService.selectWorkflowProductList(workflowProduct,page,size);
    }

    @PostMapping("")
    public Result<WorkflowProduct> addWorkflowProduct(@RequestBody WorkflowProduct workflowProduct){
        return workflowProductService.addWorkflowProduct(workflowProduct);
    }

    @GetMapping("/{id}")
    public Result<WorkflowProduct> getWorkflowProductById(@PathVariable Integer id){
        return workflowProductService.selectWorkflowProductById(id);
    }
}
